package com.yanqu.road.server.cmd.passRoad;

import com.yanqu.road.entity.log.LogOpenMiniGameFinish;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.pass.RoadProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.manger.system.MiniGameConfigMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_PASS_ROAD_OPEN_MINIGAME_FINISH, desc = "开局小游戏完成的小游戏ID")
public class PassRoadOpenGameFinishCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        RoadProto.OpenMiniGameFinishReqMsg reqMsg = RoadProto.OpenMiniGameFinishReqMsg.parseFrom(packet.getBytes());
        int gameId = reqMsg.getGameId();
        if (!MiniGameConfigMgr.hasMiniGame(gameId)) {
            log.error("PassRoadOpenGameFinishCmd gameId={} not found!!", gameId);
            return;
        }
        AutoLogMgr.add(new LogOpenMiniGameFinish(player.getUserId(), gameId));
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
